package org.ucn.dmaa0914.temadesign.group2.modelLayer;

import org.ucn.dmaa0914.temadesign.group2.tuiLayer.Application;
import java.util.Date;

/**
 * The Copy class represents a copy of a DVD
 * 
 * @author Kim Johannsen
 * @version 05-11-2014
 */
public class Copy
{
    private static int idCounter = 1;
    
    private int id;
    private Dvd dvd;
    private String serialNumber;
    private Date purchaseDate;
    private double purchasePrice;
    private String notes;
    private Loan currentLoan;
    
    public Copy(Dvd dvd, String serialNumber, Date purchaseDate, double purchasePrice, String notes)
    {
        this.id = idCounter++;
        
        this.currentLoan = null;
        this.dvd = dvd;
        this.serialNumber = serialNumber;
        this.purchaseDate = purchaseDate;
        this.purchasePrice = purchasePrice;
        this.notes = notes;
    }
    
    public String makeDescription()
    {
        return "ID: " + String.valueOf(getId()) + "\n" +
               "DVD: " + getDvd().toString() + "\n" +
               "Serial Number: " + getSerialNumber() + "\n" +
               "Purchase Date: " + Application.instance.dateFormat.format(getPurchaseDate()) + "\n" +
               "Purchase Price: " + String.valueOf(getPurchasePrice()) + " DKK\n" +
               "Notes: " + getNotes() + "\n" +
               "Current Lent Out To: " + currentLoan == null ? "Available" : currentLoan.toString();
    }
    
    public String toString()
    {
        return serialNumber + " (" + dvd.getTitle() + ")";
    }
    
    public void setCurrentLoan(Loan loan)
    {
        this.currentLoan = loan;
    }
    
    public void setId(int id)
    {
        this.id = id;
    }
    
    public void setSerialNumber(String serialNumber)
    {
        this.serialNumber = serialNumber;
    }
    
    public void setPurchaseDate(Date purchaseDate)
    {
        this.purchaseDate = purchaseDate;
    }
    
    public void setPurchasePrice(double price)
    {
        this.purchasePrice = price;
    }
    
    public void setNotes(String notes)
    {
        this.notes = notes;
    }
    
    public int getId()
    {
        return id;
    }
    
    public Loan getCurrentLoan()
    {
        return currentLoan;
    }
    
    public String getSerialNumber()
    {
        return serialNumber;
    }
    
    public Date getPurchaseDate()
    {
        return purchaseDate;
    }
    
    public double getPurchasePrice()
    {
        return purchasePrice;
    }
    
    public String getNotes()
    {
        return notes;
    }
    
    public Dvd getDvd()
    {
        return dvd;
    }
}
